<?php
/**
 * @author: zhouzhongyuan <435690026@qq.com>
 */


namespace webservice\helpers;


use SoapServer;

class WebService
{
    public $controller = '';


    public function getInfo($param = [])
    {
        return $_POST = $param;
//        return $this->info;
    }

    public function handle($obj, $url = null, $uri = 'soap')
    {
        is_null($url) && $url = \Yii::$app->urlManager->createAbsoluteUrl(\Yii::$app->controller->getRoute());
        $s = new SoapServer(null, array("location" => $url, "uri" => $uri));
        $s->setObject($obj);
        $s->handle();
    }

    public static function isSoap()
    {
        return strpos($_SERVER['HTTP_USER_AGENT'], 'SOAP');
    }

}